#include #include #include using std::ifstream; using std::ostream; using std::ios_base; using std::string; using std::cout; using std::cin; using std::endl; void main() { int A[10]; //static memory allocation //the variable A is a pointer to the array of 10 ints //dynamic memory allocation //we need a pointer to point to memory that the OS will give us at runtime int x = 8; int* p = NULL; //p is a pointer to an integer, initialized to NULL p = &x; // makes p point to the address of the integer x cout << &x << endl; cout << p << endl; cout << *p << endl; // * gets the value at an address cout << &p << endl; cout << **&*&*&*&*&*&*&*&*&*&p << endl; p = new int; *p = 999; cout << *p << endl; delete p; for(int i = 0; i < 100000; i++) { p = new int; delete p; } cout << "done" << endl; p = new int[1000]; p[0] = 10; delete[] p; }